﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TARS.AdminCP
{
    public partial class FeedBack : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        protected void btnViewFeedBack_Click(object sender, EventArgs e)
        {
            if (RadGrid1.SelectedValues != null)
            {
                RadAjaxPanel2.Visible = true;
                Guid FeedBackID = new Guid(RadGrid1.SelectedValues["ID"].ToString());
                Session["FeedBackID"] = RadGrid1.SelectedValues["ID"].ToString();
                using (var db = new TARSDelivery_EprojectEntities())
                {
                    var getFeedback = db.t_FeedBack.First(x => x.ID == FeedBackID);
                    txtFullName.Text = getFeedback.CustomerFullName;
                    txtEmail.Text = getFeedback.CustomerEmail;
                    txtPhone.Text = getFeedback.CustomerPhone;
                    rtRating.Value = Convert.ToDecimal(getFeedback.Rating);
                    RadEditor1.Content = getFeedback.FeedBack;
                }

            }
        }

        protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RadAjaxPanel2.Visible = false;
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Guid FeedBackID = new Guid(Session["FeedBackID"].ToString());
            using (var db = new TARSDelivery_EprojectEntities())
            {
                t_FeedBack getFeedback = db.t_FeedBack.First(x => x.ID == FeedBackID);
                if (getFeedback.Status == true)
                    getFeedback.Status = false;
                else
                    getFeedback.Status = true;
                db.SaveChanges();
                RadAjaxPanel2.Visible = false;
                RadGrid1.Rebind();
            }
        }
    }
}